package org.jweb.demo.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "jweb_demo_goods", schema = "")
@DynamicUpdate(true)
@DynamicInsert(true)
@SuppressWarnings("serial")
public class DemoGoodsEntity {

	private String id;
	private String name;
	private Set<DemoGoodsTypeREntity> typeSet;
	private Set<DemoGoodsPicEntity> picSet;
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
	@Column(name ="id",nullable=false,length=32)
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(name ="name",nullable=true,length=32)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@OneToMany(cascade=CascadeType.ALL,mappedBy="goodsEntity")//　OneToMany关联到了AdminRole这个类，由AdminRole这个类来维护多对一的关系，mappedBy="admin"
	@LazyCollection(LazyCollectionOption.EXTRA)//
	public Set<DemoGoodsTypeREntity> getTypeSet() {
		return typeSet;
	}
	public void setTypeSet(Set<DemoGoodsTypeREntity> typeSet) {
		this.typeSet = typeSet;
	}
	
	@OneToMany(cascade=CascadeType.ALL,mappedBy="goodsEntity")//　OneToMany关联到了AdminRole这个类，由AdminRole这个类来维护多对一的关系，mappedBy="admin"
	@LazyCollection(LazyCollectionOption.EXTRA)//
	public Set<DemoGoodsPicEntity> getPicSet() {
		return picSet;
	}
	
	public void setPicSet(Set<DemoGoodsPicEntity> picSet) {
		this.picSet = picSet;
	}
	
}
